package com.jwds.digital.bios.business.core.infrastructure.dto.belt.assembler;

import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltPerformanceWeekReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltPerformanceWeekRespVO;
import com.jwds.digital.bios.business.core.infrastructure.entity.belt.BeltPerformanceWeek;
import java.util.Objects;

/**
 * BeltPerformanceWeek DTO与Entity之间的相互转换
 *
 * @author 林柏云
 * @date 2024-10-24
 */
public class BeltPerformanceWeekAssembler {

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @return 实体对象
  */
  public static BeltPerformanceWeek dto2entity(BeltPerformanceWeekReqDTO dto)  {
    if (dto == null) {
      return null;
    }
    BeltPerformanceWeek entity = new BeltPerformanceWeek();
    entity.setBeltId(dto.getBeltId());
    entity.setAvgLoadRate(dto.getAvgLoadRate());
    entity.setAvgNoLoadRate(dto.getAvgNoLoadRate());
    entity.setLoadRateRatio(dto.getLoadRateRatio());
    entity.setWorkRate(dto.getWorkRate());
    entity.setWorkEfficiency(dto.getWorkEfficiency());
    entity.setNoLoadPowerConsumption(dto.getNoLoadPowerConsumption());
    entity.setLoadPowerConsumption(dto.getLoadPowerConsumption());
    entity.setNoLoadRuntime(dto.getNoLoadRuntime());
    entity.setLoadRuntime(dto.getLoadRuntime());
    entity.setOperationEfficiency(dto.getOperationEfficiency());
    entity.setSpikePowerConsumption(dto.getSpikePowerConsumption());
    entity.setPeakPowerConsumption(dto.getPeakPowerConsumption());
    entity.setValleyPowerConsumption(dto.getValleyPowerConsumption());
    entity.setFlatPowerConsumption(dto.getFlatPowerConsumption());
    entity.setTotalPowerConsumption(dto.getTotalPowerConsumption());
    entity.setDataTime(dto.getDataTime());
    return entity;
  }

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @param entity 原实体对象
  * @return 实体对象
  */
  public static BeltPerformanceWeek dto2entity(BeltPerformanceWeekReqDTO dto, BeltPerformanceWeek entity){
    if (dto == null) {
      return null;
    }
    if(Objects.nonNull(dto.getBeltId())) {
      entity.setBeltId(dto.getBeltId());
    }
    if(Objects.nonNull(dto.getAvgLoadRate())) {
      entity.setAvgLoadRate(dto.getAvgLoadRate());
    }
    if(Objects.nonNull(dto.getAvgNoLoadRate())) {
      entity.setAvgNoLoadRate(dto.getAvgNoLoadRate());
    }
    if(Objects.nonNull(dto.getLoadRateRatio())) {
      entity.setLoadRateRatio(dto.getLoadRateRatio());
    }
    if(Objects.nonNull(dto.getWorkRate())) {
      entity.setWorkRate(dto.getWorkRate());
    }
    if(Objects.nonNull(dto.getWorkEfficiency())) {
      entity.setWorkEfficiency(dto.getWorkEfficiency());
    }
    if(Objects.nonNull(dto.getNoLoadPowerConsumption())) {
      entity.setNoLoadPowerConsumption(dto.getNoLoadPowerConsumption());
    }
    if(Objects.nonNull(dto.getLoadPowerConsumption())) {
      entity.setLoadPowerConsumption(dto.getLoadPowerConsumption());
    }
    if(Objects.nonNull(dto.getNoLoadRuntime())) {
      entity.setNoLoadRuntime(dto.getNoLoadRuntime());
    }
    if(Objects.nonNull(dto.getLoadRuntime())) {
      entity.setLoadRuntime(dto.getLoadRuntime());
    }
    if(Objects.nonNull(dto.getOperationEfficiency())) {
      entity.setOperationEfficiency(dto.getOperationEfficiency());
    }
    if(Objects.nonNull(dto.getSpikePowerConsumption())) {
      entity.setSpikePowerConsumption(dto.getSpikePowerConsumption());
    }
    if(Objects.nonNull(dto.getPeakPowerConsumption())) {
      entity.setPeakPowerConsumption(dto.getPeakPowerConsumption());
    }
    if(Objects.nonNull(dto.getValleyPowerConsumption())) {
      entity.setValleyPowerConsumption(dto.getValleyPowerConsumption());
    }
    if(Objects.nonNull(dto.getFlatPowerConsumption())) {
      entity.setFlatPowerConsumption(dto.getFlatPowerConsumption());
    }
    if(Objects.nonNull(dto.getTotalPowerConsumption())) {
      entity.setTotalPowerConsumption(dto.getTotalPowerConsumption());
    }
    if(Objects.nonNull(dto.getDataTime())) {
      entity.setDataTime(dto.getDataTime());
    }
    return entity;
  }

  /**
  * 将实体对象转换为传输对象
  *
  * @param entity 实体对象
  * @return 传输对象
  */
  public static BeltPerformanceWeekRespVO entity2dto(BeltPerformanceWeek entity) {
    if (entity == null) {
      return null;
    }
    BeltPerformanceWeekRespVO dto = new BeltPerformanceWeekRespVO();
    dto.setId(entity.getId());
    dto.setBeltId(entity.getBeltId());
    dto.setAvgLoadRate(entity.getAvgLoadRate());
    dto.setAvgNoLoadRate(entity.getAvgNoLoadRate());
    dto.setLoadRateRatio(entity.getLoadRateRatio());
    dto.setWorkRate(entity.getWorkRate());
    dto.setWorkEfficiency(entity.getWorkEfficiency());
    dto.setNoLoadPowerConsumption(entity.getNoLoadPowerConsumption());
    dto.setLoadPowerConsumption(entity.getLoadPowerConsumption());
    dto.setNoLoadRuntime(entity.getNoLoadRuntime());
    dto.setLoadRuntime(entity.getLoadRuntime());
    dto.setOperationEfficiency(entity.getOperationEfficiency());
    dto.setSpikePowerConsumption(entity.getSpikePowerConsumption());
    dto.setPeakPowerConsumption(entity.getPeakPowerConsumption());
    dto.setValleyPowerConsumption(entity.getValleyPowerConsumption());
    dto.setFlatPowerConsumption(entity.getFlatPowerConsumption());
    dto.setTotalPowerConsumption(entity.getTotalPowerConsumption());
    dto.setDataTime(entity.getDataTime());
    dto.setCreateUser(entity.getCreateUser());
    dto.setCreateTime(entity.getCreateTime());
    dto.setModifyUser(entity.getModifyUser());
    dto.setModifyTime(entity.getModifyTime());
    return dto;
  }

}
